/**
* Javascipt Library for alert dialog
* @Ray Li
* dependency
* <link rel="stylesheet" type="text/css" href="js/components/yui/fonts/fonts-min.css" />
* <link rel="stylesheet" type="text/css" href="js/components/yui/button/assets/skins/sam/button.css" />
* <link rel="stylesheet" type="text/css" href="css/yui/container/alertdialog.css" />
* <script type="text/javascript" src="js/components/yui/yahoo-dom-event/yahoo-dom-event.js"></script>
* <script type="text/javascript" src="js/components/yui/element/element-beta.js"></script>
* <script type="text/javascript" src="js/components/yui/button/button.js"></script>
* <script type="text/javascript" src="js/components/yui/container/container.js"></script>
*/

    //Create a SimpleDialog used to mimic an OS dialog
    var alertdialog = new YAHOO.widget.SimpleDialog('alert', {
        fixedcenter: true,
        visible: false,
        modal: true,
        width: '300px',
        constraintoviewport: true, 
        icon: YAHOO.widget.SimpleDialog.ICON_WARN,
        buttons: [
            { text: '确定', handler: function() {
                alertdialog.hide();
            }, isDefault: true }
        ]
    });
    
    var alertdialog_2 = new YAHOO.widget.SimpleDialog('alert_2', {
        fixedcenter: true,
        visible: false,
        modal: true,
        width: '300px',
        constraintoviewport: true, 
        icon: YAHOO.widget.SimpleDialog.ICON_WARN,
        buttons: [
            { text: '确定', handler: function() {
                alertdialog_2.hide();
                window.parent.parent.location = "/conghua/login.html";
            }, isDefault: true }
        ]
    });
    
    var alertdialog_3 = new YAHOO.widget.SimpleDialog('alert_3', {
        fixedcenter: true,
        visible: false,
        modal: true,
        width: '300px',
        constraintoviewport: true, 
        icon: YAHOO.widget.SimpleDialog.ICON_WARN,
        buttons: [
            { text: '确定', handler: function() {
                alertdialog_3.hide();
                getTaskInstancesByUser();
				getTaskInstancesByGroup();
            }, isDefault: true }
        ]
    });
    
    var alertdialog_4 = new YAHOO.widget.SimpleDialog('alert_4', {
        fixedcenter: true,
        visible: false,
        modal: true,
        width: '300px',
        constraintoviewport: true, 
        icon: YAHOO.widget.SimpleDialog.ICON_WARN,
        buttons: [
            { text: '确定', handler: function() {
                alertdialog_4.hide();
                removeItemFromTree();
            }, isDefault: true },
            { text: '取消', handler: function() {
                alertdialog_4.hide();
            }, isDefault: false }
        ]
    });
    
    var alertdialog_5 = new YAHOO.widget.SimpleDialog('alert_5', {
        fixedcenter: true,
        visible: false,
        modal: true,
        width: '300px',
        constraintoviewport: true, 
        icon: YAHOO.widget.SimpleDialog.ICON_WARN,
        buttons: [
            { text: '确定', handler: function() {
                alertdialog_5.hide();
                exportAllProcesses();
            }, isDefault: true },
            { text: '取消', handler: function() {
                alertdialog_5.hide();
            }, isDefault: false }
        ]
    });
    
    var alertdialog_8 = new YAHOO.widget.SimpleDialog('alert_8', {
        fixedcenter: true,
        visible: false,
        modal: true,
        width: '300px',
        constraintoviewport: true, 
        icon: YAHOO.widget.SimpleDialog.ICON_WARN,
        buttons: [
            { text: '确定', handler: function() {
                alertdialog_8.hide();
                window.parent.parent.location = "../../login.html";
            }, isDefault: true }
        ]
    });
    
    
    //Create an alert method
    alertMessage = function( message ) {
        //Set the header
        alertdialog.setHeader('提示');
        //Give the body something to render with
        alertdialog.setBody('Notta');
        //Render the Dialog to the body
        alertdialog.render(document.body);

        //Set the body to the string passed
        alertdialog.setBody(message);
        //Set an icon
        alertdialog.cfg.setProperty('icon', YAHOO.widget.SimpleDialog.ICON_WARN);
        //Bring the dialog to the top
        alertdialog.bringToTop();
        //Show it
        alertdialog.show();
    };
    
    //Create an alert method
    alertMessage_2 = function( message ) {
        //Set the header
        alertdialog_2.setHeader('提示');
        //Give the body something to render with
        alertdialog_2.setBody('Notta');
        //Render the Dialog to the body
        alertdialog_2.render(document.body);

        //Set the body to the string passed
        alertdialog_2.setBody(message);
        //Set an icon
        alertdialog_2.cfg.setProperty('icon', YAHOO.widget.SimpleDialog.ICON_WARN);
        //Bring the dialog to the top
        alertdialog_2.bringToTop();
        //Show it
        alertdialog_2.show();
    };
    
    //Create an alert method
    alertMessage_3 = function( message ) {
        //Set the header
        alertdialog_3.setHeader('提示');
        //Give the body something to render with
        alertdialog_3.setBody('Notta');
        //Render the Dialog to the body
        alertdialog_3.render(document.body);

        //Set the body to the string passed
        alertdialog_3.setBody(message);
        //Set an icon
        alertdialog_3.cfg.setProperty('icon', YAHOO.widget.SimpleDialog.ICON_WARN);
        //Bring the dialog to the top
        alertdialog_3.bringToTop();
        //Show it
        alertdialog_3.show();
    };
    
    //Create an alert method
    alertMessage_4 = function( message ) {
        //Set the header
        alertdialog_4.setHeader('提示');
        //Give the body something to render with
        alertdialog_4.setBody('Notta');
        //Render the Dialog to the body
        alertdialog_4.render(document.body);

        //Set the body to the string passed
        alertdialog_4.setBody(message);
        //Set an icon
        alertdialog_4.cfg.setProperty('icon', YAHOO.widget.SimpleDialog.ICON_WARN);
        //Bring the dialog to the top
        alertdialog_4.bringToTop();
        //Show it
        alertdialog_4.show();
    };
    
    //Create an alert method
    alertMessage_5 = function( message ) {
        //Set the header
        alertdialog_5.setHeader('提示');
        //Give the body something to render with
        alertdialog_5.setBody('Notta');
        //Render the Dialog to the body
        alertdialog_5.render(document.body);

        //Set the body to the string passed
        alertdialog_5.setBody(message);
        //Set an icon
        alertdialog_5.cfg.setProperty('icon', YAHOO.widget.SimpleDialog.ICON_WARN);
        //Bring the dialog to the top
        alertdialog_5.bringToTop();
        //Show it
        alertdialog_5.show();
    };

	//Create an alert method
    alertMessage_8 = function( message ) {
        //Set the header
        alertdialog_8.setHeader('提示');
        //Give the body something to render with
        alertdialog_8.setBody('Notta');
        //Render the Dialog to the body
        alertdialog_8.render(document.body);

        //Set the body to the string passed
        alertdialog_8.setBody(message);
        //Set an icon
        alertdialog_8.cfg.setProperty('icon', YAHOO.widget.SimpleDialog.ICON_WARN);
        //Bring the dialog to the top
        alertdialog_8.bringToTop();
        //Show it
        alertdialog_8.show();
    };
	
    //Create a SimpleDialog used to pop up message
    var infodialog = new YAHOO.widget.SimpleDialog('message', {
        fixedcenter: true,
        visible: false,
        modal: false,
        width: '300px',
        constraintoviewport: true, 
        icon: YAHOO.widget.SimpleDialog.ICON_INFO,
        buttons: [
            { text: '确定', handler: function() {
                infodialog.hide();
            }, isDefault: true }
        ]
    });


    //Create an alert method
    alertInfo = function( message ) {
        //Set the header
        infodialog.setHeader('信息');
        //Give the body something to render with
        infodialog.setBody('Notta');
        //Render the Dialog to the body
        infodialog.render(document.body);

        //Set the body to the string passed
        infodialog.setBody(message);
        //Set an icon
        infodialog.cfg.setProperty('icon', YAHOO.widget.SimpleDialog.ICON_INFO);
        //Bring the dialog to the top
        infodialog.bringToTop();
        //Show it
        infodialog.show();
    };
    
    //
    //create a waiting dialog
    
    loadingDialog = new YAHOO.widget.Panel("wait", { 
        width: "240px", 
        fixedcenter: true, 
        close: false, 
        draggable: false, 
        zindex:4,
        modal: true,
        visible: false
     });
    
     
     showLoading = function(header){
         loadingDialog.setHeader(header);
         loadingDialog.setBody("<img src=\"../../images/loading.gif\"/>");
         loadingDialog.render(document.body);
         loadingDialog.show();
     }
     
     showDeploying = function(header){
         loadingDialog.setHeader(header);
         loadingDialog.setBody("<img src=\"images/loading.gif\"/>");
         loadingDialog.render(document.body);
         loadingDialog.show();
     }
     
     hideLoading = function(){
         loadingDialog.hide();
     }
